package com.wef.modules.generator.controller;

import com.wef.common.utils.PageUtils;
import com.wef.common.utils.Query;
import com.wef.common.utils.R;
import com.wef.modules.generator.entity.PartyInfoEntity;
import com.wef.modules.generator.service.PartyInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 
 * 
 * @author xxx
 * @email xxx
 * @date 2021-02-04 14:59:39
 */
@RestController
@RequestMapping("partyinfo")
public class PartyInfoController {
	@Autowired
	private PartyInfoService partyInfoService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("partyinfo:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<PartyInfoEntity> partyInfoList = partyInfoService.queryList(query);
		int total = partyInfoService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(partyInfoList, total, query.getLimit(), query.getPage());

		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("partyinfo:info")
	public R info(@PathVariable("id") Long id){
		PartyInfoEntity partyInfo = partyInfoService.queryObject(id);
		
		return R.ok().put("partyInfo", partyInfo);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("partyinfo:save")
	public R save(@RequestBody PartyInfoEntity partyInfo){
		partyInfoService.save(partyInfo);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("partyinfo:update")
	public R update(@RequestBody PartyInfoEntity partyInfo){
		partyInfoService.update(partyInfo);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("partyinfo:delete")
	public R delete(@RequestBody Long[] ids){
		partyInfoService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
